<template>
	<div class="pages">
		<el-form :inline="true" size="small" :model="dataForm" label-width="80px">
			<el-form-item label="工厂名称:">
				<el-input v-model="dataForm.keyword" placeholder="请输入" clearable></el-input>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="getDataList()">搜索</el-button>
			</el-form-item>
		</el-form>
		<el-table :data="dataList" v-loading="dataListLoading" border style="width: 100%" header-align="center"
			:summary-method="getSummaries" show-summary>
			<el-table-column type="index" align="center" label="序号" width="60">
			</el-table-column>
			<el-table-column prop="name" align="center" label="工厂名称">
			</el-table-column>
			<el-table-column prop="order_count" align="center" label="已接单数">
			</el-table-column>
		</el-table>
		<el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
			layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
			@current-change="pageCurrentChangeHandle">
		</el-pagination>
	</div>
</template>

<script>
	import mixinViewModule from '@/mixins/view-module'
	export default {
		mixins: [mixinViewModule],
		data() {
			return {
				mixinViewModuleOptions: {
					getDataListURL: '/api/tongji/factory_tongji',
					getDataListIsPage: true,
					deleteIsBatch: true,
					createdIsNeed: true,
				},
				dataForm: {
					keyword: '',
				},
				total2: {
					factory_num: 0,
					order_num: 0
				},
			}
		},
		methods: {
			getSummaries(param) {
				const {
					columns,
					data
				} = param;
				const sums = [];
				columns.forEach((column, index) => {
					if (index === 0) {
						sums[index] = '总计';
					} else if (index === 1) {
						sums[index] = Number(this.total2.factory_num)
					} else if (index === 2) {
						sums[index] = Number(this.total2.order_num)
					}
				});
				return sums;
			},
			getTotal() {
				this.$http.post('/api/tongji/factory_tongji_total', {}).then(res => {
					console.log(res)
					this.total2.factory_num = Number(res.result.factory_num)
					this.total2.order_num = Number(res.result.order_num)
				})
			},
		},
		created() {
			this.getTotal()
		},
	}
</script>

<style>
</style>